/*
 * GetCameraDefault
 * code is similar to SetCameraDefault without the extra sets
 */
 
 
function GetCameraDefault(a)
{
	flashpoint();

	var usetVar=new Array("uset0","uset1","uset2","uset3","uset4","uset5","uset6","uset7" );
	var isetVar=new Array("iset0","iset1","iset2","iset3","iset4","iset5","iset6","iset7" );
	var setTitle=new Array("title0","title1","title2","title3","title4","title5","title6","title7" );

	var i,setting;
	
	printf('# get the user and factory default for all parameters ');
	printf('# API: GetCameraDefault(DefaultSource, PName, PNameValue )');
	printf('# get the user and factory default value ');
	printf('# OUTPUT FORMAT ');
	printf('# PName [status-factory][status-user]  default (factory) default (user) ');
	printf('# i.e. actc[0][0] 600 (factory) 600 (user)');
	printf('# actc is the parameter name');
	printf('# [0] indicates status returned is 0');
	printf('# [5] indicates status returned is 5');
	printf('# 600 is the current state of the "actc" parameter');
	printf(' ');	
	printf(' ');	
	
	writeMenu('"GetCameraDefault"','"CMD"','"GetCameraDefault()"');
	writeVariables();
	printf('declare s: title0');	
	printf('declare s: fposComm');

	printf('declare u: udummy, uuser, ufactory , ucurrent');
	printf('declare i: idummy, iuser, ifactory , icurrent');
	printf('declare s: sdummy, suser, sfactory , scurrent');
	printf('declare b: bdummy, buser, bfactory , bcurrent');
	
	
	printf('<br>','#**** OPEN FILE ****');
  	printf('outFile="/System/ZGCDef.txt"');
	writeFileOpen();

	printf('WriteLine(fd," ") ');	
	printf('WriteLine(fd," get the user and factory default for all parameters ")');
	printf('WriteLine(fd," API: GetCameraDefault(DefaultSource, PName, PNameValue )")');
	printf('WriteLine(fd," get the user and factory default value ")');
	printf('WriteLine(fd," OUTPUT FORMAT ")');
	printf('WriteLine(fd," PName [status-factory][status-user]  default (factory) default (user) ")');
	printf('WriteLine(fd," i.e. actc[0][0] 600 (factory) 600 (user)")');
	printf('WriteLine(fd," actc is the parameter name")');
	printf('WriteLine(fd," [0] indicates status returned is 0")');
	printf('WriteLine(fd," [5] indicates status returned is 5")');
	printf('WriteLine(fd," 600 is the current state of the actc parameter")');
	printf('WriteLine(fd," note that the factory and user defaults are not necessarily equal")');

	printf('WriteLine(fd," ") ');	

		printf('count=1');
		printf('LOOP:');
		printf('theType="UInt"');
		printf('fposComm=" "' );
		for( i=1 ; i< a.length ; i++)
		{ 			

 	 			printf(" ");
 				printf('if count == ', i );
  	 			printf('param=',a[i].param);
  	 			printf(setTitle[0],'="',a[i].desc,'"');

  	 			if( a[i].fposComm == "GetProductInfo")
  	 				printf('fposComm = "GetProductInfo"');
  	 			
  	 			// write theType									
 				if( a[i].type == "String" || a[i].type=="DosName")
 					printf('theType="String"','<br>');
 				else if( a[i].type=="SInt" )
 					printf('theType="SInt"','<br>'); 					
 				else if( (a[i].type=="Enum List Hex") || (a[i].type=="Hex") || (a[i].type=="Fixed") || (a[i].type=="BitMask"))
 					printf('theType="Hex"','<br>'); 					
 					
 				printf('end '); 			

				
		}// end of this HUGE for loop
		printf(' ');
		
// start to examine SetCameraDefault()
	printf('Wait(100)');
	printf(' ');
	
	printf('WriteLine(fd," ")' );
	printf('WriteLine(fd,"**** ",',setTitle[0],'," ****" )' );

 	printf(' if theType=="SInt"');
 	printf(' goto case_SINT');
 	printf(' end','<br>');

 	printf(' if theType=="String"');
 	printf(' goto case_STRING');
 	printf(' end','<br>');
	
	printf(' ' );
	printf('CASE_UINT:');
	// set user default to current state
	
	printf('# get from factory then user default ');
	printf('status=GetCameraDefault(0,param,ufactory)' );
	printf('status1=GetCameraDefault(1,param,uuser)' );

	printf('if theType != "Hex" ');
	printf('DisplayLine(count,")",param,"[",status,"][",status1,"] ", ufactory,",", uuser )' );
	printf('Write(fd,count,")",param,"[",status,"][",status1,"] ")' );
	printf('WriteLine(fd,ufactory," (factory)  ",uuser," (user)" )' );	
	printf('end','<br>');
	
	printf('if theType == "Hex" ');
	printf('bfactory=ufactory');
	printf('buser=uuser');
	printf('DisplayLine(count,")",param,"[",status,"][",status1,"] " , bfactory,",", buser )' );
	printf('Write(fd,count,") ",param,"[",status,"][",status1,"] ")' );
	printf('WriteLine(fd,bfactory," (factory)  ",buser," (user)" )' );	
	printf('end','<br>');
	
	printf('goto CONTINUE');
	printf('# UINT finished  **************************************************');		

	printf('case_SINT:');
	printf('# get from factory then user default ');

	printf('status=GetCameraDefault(0,param,ifactory)' );
	printf('status1=GetCameraDefault(1,param,iuser)' );
	printf('DisplayLine(count,")",param,"[",status,"][",status1,"] ", ifactory,",", iuser )' );
	printf('Write(fd,count,")",param,"[",status,"][",status1,"] ")' );
	printf('WriteLine(fd,ifactory," (factory)  ",iuser," (user)" )' );	
	printf('<br>');

	printf('goto CONTINUE');

	printf('# SINT finished  ***************************************************');		

	printf('case_STRING:');	
	printf('# get from factory then user default ');

	printf('status=GetCameraDefault(0,param,sfactory)' );
	printf('status1=GetCameraDefault(1,param,suser)' );
	printf('DisplayLine(count,")",param,"[",status,"][",status1,"] ", sfactory,",", suser )' );
	printf('Write(fd,count,")",param,"[",status,"][",status1,"] ")' );
	printf('WriteLine(fd,sfactory," (factory)  ",suser," (user)" )' );	
	printf('<br>');
		
	printf('# STRING finished  ************************************************');		


	printf('CONTINUE:');
	printf(' ');
	
	printf("# a GetProductInfo call*****************************");
	printf(' if fposComm == "GetProductInfo"');
	printf(' WriteLine(fd,count,")for ",param," use GetProductInfo()")');
	printf(' end ');
	printf(' ');

	printf('if count<', a.length-1 );
	printf('count=count+1 ');
	printf('goto LOOP');
	printf('end');
	
	writeFileClose();
	printf('exitscript');

}

